# -*- coding: utf-8 -*-

from django.db import models


CHIP = ( 
    ("MCU", "MCU"),  
    ("BLE", "BLE"),
    ("WiFi", "WiFi"),
    ("ZigBee", "ZigBee"),
    ("WiFi+BLE", "WiFi+BLE"),
    ("BLE+ZigBee", "BLE+ZigBee"),
)


PRODUCT = ( 
    ("芯片", "芯片"),  
    ("模组", "模组"),
    ("开发板", "开发板"),
)


class Chipset(models.Model): 
    '''芯片类型''' 
    name = models.CharField("芯片型号", max_length=100)  
    display = models.BooleanField("用户可见", default=True)
    guest = models.BooleanField("访客可见", default=False)
    category = models.CharField("芯片类型", max_length=10, choices=CHIP, default="MCU")
     
    class Meta:
        verbose_name = "芯片类型"
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.name
  
  
class Product(models.Model):
    '''产品信息
    
    '''
    name = models.CharField("产品名称", max_length=100)
    recommend = models.BooleanField("推荐", default=False)
    display = models.BooleanField("用户可见", default=True)
    guest = models.BooleanField("访客可见", default=False)
    category = models.CharField("产品类型", max_length=10, choices=PRODUCT, default="芯片")
    image = models.ImageField(upload_to="upload/img/", verbose_name="图标", null=True, blank=True)
    description = models.CharField("描述", max_length=200, null=True, blank=True, help_text="限200个字符")
    forum = models.CharField("论坛", max_length=200, null=True, blank=True)
    code = models.CharField("代码", max_length=200, null=True, blank=True)
    doc = models.CharField("文档", max_length=200, null=True, blank=True)
    date = models.DateTimeField("发布日期", auto_now_add=True)

    class Meta:
        verbose_name = "产品信息"
        verbose_name_plural = verbose_name
        ordering = ['name', 'date']

    def __str__(self):
        return self.name
    

    
    
    

 

    
    